<?php
require('config.php');

$id = intval($_POST['id']);
$startUrl = cleanValue($_POST['startUrl']);

$filterUrl = cleanValue($_POST['filterUrl']);
$filterString = base64_encode($_POST['filterString']);
$urlAdd = cleanValue($_POST['urlAdd']);

$filterDetail = cleanValue($_POST['filterDetail']);
$name = cleanValue($_POST['name']);
$removeDom = cleanValue($_POST['removeDom']);
$filterContentString = base64_encode($_POST['filterContentString']);

$limitUrl = intval($_POST['limitUrl']);

$sqlAdd = "INSERT INTO sites (id, `name`, home_url, detail_filter_type, link_filter_type, link_filter_string, filter_string, dom_remove, `limit`, link_before) VALUES(
            $id, '$name', '$startUrl', '$filterDetail', '$filterUrl', '$filterString', '$filterContentString', '$removeDom', '$limitUrl', '$urlAdd')
        ON DUPLICATE KEY UPDATE name = '$name', home_url = '$startUrl', detail_filter_type = '$filterDetail',
            link_filter_type = '$filterUrl', link_filter_string = '$filterString', link_before = '$urlAdd', filter_string = '$filterContentString', dom_remove = '$removeDom', `limit` = '$limitUrl'
	";
try{
	if(mysql_query($sqlAdd)){
		die('1');
	}
	else{
		die('0');
	}
}
catch(Exception $e){
	die('0');
}